package campus.service.impl;

import campus.mapper.ProofMapper;
import campus.model.AccountExample;
import campus.model.Proof;
import campus.model.ProofExample;
import campus.service.ProofService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：wang
 * @description：TODO
 * @date ：2020/5/9 3:43
 */
@Service
public class ProofServiceImpl implements ProofService {
    @Autowired
    private ProofMapper proofMapper;
    @Override
    public List<Proof> selectByExample(ProofExample example) {
        return proofMapper.selectByExample(example);
    }

    @Override
    public int insert(Proof record) {
        if ("是".equals(record.getpDefault())){
            proofMapper.updatepDefaultAll();
        }
        return proofMapper.insert(record);
    }

    @Override
    public int deleteByPrimaryKey(Integer pId) {
        return proofMapper.deleteByPrimaryKey(pId);
    }

    @Override
    public int updateByPrimaryKeySelective(Proof record) {
        if ("是".equals(record.getpDefault())){
            proofMapper.updatepDefaultAll();
        }
        return proofMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public Proof findByPrimaryKey(Integer pId) {
        return proofMapper.selectByPrimaryKey(pId);
    }
}
